package com.dingdayu.club.admin.common.util;

import android.content.Context;
import android.content.SharedPreferences;
import android.util.Log;

import com.dingdayu.club.admin.MainActivity;

public class SharePreferenceUtil {

	public static final String SP_FILE_NAME = "club_admin";
	private static SharedPreferences sp;
	private static SharedPreferences.Editor editor;
	public static final String TAG = SharePreferenceUtil.class.getName();

	public SharePreferenceUtil( String file) {
		Log.i(TAG,file);
		if(file == "")
			file = SP_FILE_NAME;
		sp = MainActivity.mainActivity.getSharedPreferences(file, Context.MODE_PRIVATE);
		editor = sp.edit();
	}

	public static int getClubID(){
		int corp_id = sp.getInt("corp_id", 0);
		Log.i(TAG,"GET:Corp_id:"+corp_id);
		return corp_id;
	}

	// appid
	public void setAppId(String appid) {
		Log.i(TAG,"SET:");
		// TODO Auto-generated method stub
		editor.putString("appid", appid);
		editor.commit();
	}

	public static void setValue(String key,String value){
		Log.i(TAG,"SET:"+key+":"+value);
		editor.putString(key,value);
		editor.commit();
	}

	public static String getValue(String key) {
		String value = sp.getString(key, "");
		Log.i(TAG,"GET:"+key+"="+value);
		return value;
	}

	public static void remove(String key){
		Log.i(TAG,"remove:"+key);
		editor.remove(key);
	}
}
